<extend name="Base/common"/>
<block name="head_css">
<link href="__PUBLIC__/Green/css/usercenter.css" rel='stylesheet' type='text/css' />
</block>
<block name="head_script">
    <script type="text/javascript" src="__PUBLIC__/Green/js/usercenter.js"></script>
</block>
<block name="body">
    <div class="width1000">
        <div class="top_tit">
            <a href="{:U('User/index')}">用户中心</a> &gt;&gt; 我的账号 &gt;&gt; 车辆管理
        </div>
        <div class="clearfix relative">
            <include file="User/nav" />
            <div class="user_center">
                <div class="user_car">
                    <div class="profile_tit">
                       我的车辆
                    </div>
                    <div class="user_add">
                    	<a class="user_add_btn">添加</a>
                    </div>
                    <div id="user_cars">
                    <empty name="cars">
                        &nbsp;暂无车辆 
                    <else />
                    <volist name="cars" id="car">
                    <div class="profile_car">
                        <div class="clearfix profile_word">
                            <div class="span3 f_l">
                                车  牌  号：{$car.c_lcn_no}
                            </div>
                            <div class="span6 f_l">
                                车        型：{$car.c_vehicle_name}
                            </div>
                            <div class="span1 f_l t_r">
                                <!--<a href="javascript:void(0);" class="car_del">删除</a>-->
                            </div>
                        </div>
                        <div class="clearfix profile_word has_border">
                            <div class="span3 f_l">
                                发动机号：{$car.c_eng_no}
                            </div>
                            <div class="span6 f_l">
                                车   架   号：{$car.c_vhl_frm}
                            </div>
                               <div>
                    </div>
                    <eq name="car['dele']" value="1">
                    <a href="{:U('User/delCar')}?car_id={$car.car_id}" class="car_del_btn">删除</a>
                    </eq>
                        </div>
                     
                    </div>
                    
                    </volist>
                    <div class="onethink pagination pagination-right">
                    	{$_page}
                    </div>
                    </empty>
                    </div>
                </div>
                
                <div class="hide" id="add_car">
                <form action="{:U('user/addCar')}" method="post" class="form-horizontal" id="add_forms" >
                	<div class="profile_person">
               		 <div class="form-group">
                            <label class="col-sm-2 control-label">车牌号：</label>
                            <div class="col-sm-6">
                                <input type="text" name="c_lcn_no" class="form-control" id="c_lcn_no" placeholder="车牌号" />
                            </div>
                            <label class="inptu_err c_lcn_no"></label>
                      </div>
                      
                      
                      <div class="form-group">
                            <label class="col-sm-2 control-label">品牌：</label>
                            <div class="col-sm-6">
                                <select name="brand" id="brand" style=" width: 28%;">
			                        <volist name="brands" id="item">
			                            <option value="{$item.brand_id}">{$item.brand_alpha}-{$item.brand_name}</option>
			                       
			                        </volist>
			                        </select>
			                        <select name="series" id="series" style="width: 28%;">
			                            <option value="">车系</option>
			                        </select>
						            <select name="model" id="model" style="width: 41%">
			                           <option value="">车型</option>
			                       </select>
			                     
			                     
                            </div>
                      </div>
                      
                <div class="form-group">
                            <label class="col-sm-2 control-label">车架号：</label>
                            <div class="col-sm-6">
                                <input type="text" name="c_vhl_frm" class="form-control" id="c_vhl_frm" placeholder="车架号" />
                            	
                            </div>
                            <label class="inptu_err c_vhl_frm"></label>
                      </div>
                      <div class="form-group">
                            <label class="col-sm-2 control-label">发动机号：</label>
                            <div class="col-sm-6">
                                <input type="text" name="c_eng_no" class="form-control" id="c_eng_no" placeholder="发动机号" />
                            </div>
                            <label class="inptu_err c_eng_no"></label>
                      </div>
                      <div class="form-group">
                            <label class="col-sm-2 control-label">登记日期：</label>
                            <div class="col-sm-6">
                                <input type="text" name="c_fst_reg_dte" class="form-control datePicker" id="c_fst_reg_dte" placeholder="登记日期" />
                            </div>
                            <label class="inptu_err c_fst_reg_dte"></label>
                      </div>
                       <div class="form-group">
                            <label class="col-sm-2 control-label">保险公司：</label>
                            <div class="col-sm-6">
                            
                            	<select name="insurer" id="insurer" style=" width: 100%;">
                            	 	<volist name="insurer" id="item">
                            	 		<option value="{$item.insurer_id}">{$item.insurer_name}</option>
                                	 </volist>
                                </select>
                                
                            </div>
                      </div>
                      </div>
            </form>
             </div>   
            
        </div>
               </div>
    </div>
</block>    
<block name="script">
<script type="text/javascript" src="__PUBLIC__/Green/js/insurance.js"></script>
<script type="text/javascript" src="__PUBLIC__/Green/js/jquery.jeditable.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/Green/js/PCASClass.js"></script>
<script type="text/javascript" src="__PUBLIC__/Green/js/datePicker.js"></script>
<script type="text/javascript">
    highlight_nav("{:U('User/car')}");
    highlight_nav("javascript:void(0);");
    var saveUrl = "{:U('User/saveinfo')}";
    var add=true;
    $(".user_add_btn").on("click",function(){
    	if(add){
    		$(".user_add_btn").text("保存");
    		$("#add_car").removeClass("hide");
    		$("#user_cars").addClass("hide");
    		add=false;
    	}else{
    		var check=false;
    		if($("#c_lcn_no").val()==''){
    			$(".c_lcn_no").text("请填写车牌号");
    			$(".c_lcn_no").fadeIn();
    			check=true;
    			
    		}else if(!checkPlateNumber($("#c_lcn_no").val())){
    			$(".c_lcn_no").text("请填写正确的车牌号");
    			$(".c_lcn_no").fadeIn();
    			check=true;

    		}
    		if($("#c_vhl_frm").val()==''){
    			$(".c_vhl_frm").text("请填写车架号")
    			$(".c_vhl_frm").fadeIn();
    			check=true;
    			
    		}
    		if($("#c_eng_no").val()==''){
    			$(".c_eng_no").text("请填写发动机号")
    			$(".c_eng_no").fadeIn();
    			check=true;
    		}
    		if($("#c_fst_reg_dte").val()==''){
    			$(".c_fst_reg_dte").text("请选择日期")
    			$(".c_fst_reg_dte").fadeIn();
    			check=true;
    		}
				    		
    		if(check){
    			return;
    		}else{
        		$('#add_forms').submit();
    		}
    	}           
    });
 	$(":input").on("focus",function() {  
 	    $("."+this.id).hide();
 	});
 	$(":input").on("blur",function() {  
 		if($(this).val()==''){
 	    $("."+this.id).fadeIn();
 		}
 	});
    $('#brand').change(function(){
        var bId = $(this).val();
        $.post("{:U('Premium/getSeries')}","id="+bId,function(data){
            if(data.status){
                var series = $('#series'),models = $('#model');
                series.html('');
                models.html('');
                for(var i=0;i<data.info.length;i++){
                    var o = data.info[i];
                    $('<option value="' + o.series_id + '">' + o.series_name + '</option>').appendTo(series);
                }
                $('#series').trigger('change');
            }else{
                alert(data.info);
            }
        },'json');
    });
    $('#series').change(function(){
        var sId = $(this).val();
        $.post("{:U('Premium/getModel')}","id="+sId,function(data){
            if(data.status){
                var models = $('#model');
                models.html('');
                for(var i=0;i<data.info.length;i++){
                    var o = data.info[i];
                    $('<option value="' + o.model_id + '">' + o.model_name + '</option>').appendTo(models);
                }
            }else{
                alert(data.info);
            }
        },'json');
    });
    
    $('#brand').trigger('change');
    
</script>
</block>
